{include file="common/header"}.
<style>
	#form-icon-preview {
		float: left;
		width: 34px;
		height: 36px;
		line-height: 36px;
		font-size: 30px !important;
		border: 1px solid #e6e6e6;
		text-align: center;
		border-radius: 3px;
	}
</style>
<div class="x-body">
	<form class="layui-form" action="">
		<div class="layui-form-item">
			<label class="layui-form-label">所属菜单</label>
			<div class="layui-input-inline">
				<select name="parent_id" lay-verify="required">
					<option value="0">顶级菜单</option>
					{foreach $menu as $vo}
					<option value="{$vo.id}" {if $info.parent_id== $vo.id}selected{
					/if}>{:html_entity_decode($vo.str)}{$vo.title}</option>
					{/foreach}
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">菜单名称</label>
			<div class="layui-input-inline">
				<input type="text" name="title" value="{$info.title}" required lay-verify="required"
				       placeholder="请输入菜单名称" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">所属控制器</label>
			<div class="layui-input-inline">
				<input type="text" name="controller" value="{$info.controller}" required placeholder="请输入所属控制器"
				       autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">操作方法</label>
			<div class="layui-input-inline">
				<input type="text" name="methods" value="{$info.methods}" required placeholder="请输入操作方法"
				       autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">显示到菜单</label>
			<div class="layui-input-inline">
				<input type="checkbox" name="is_nav" {if $info.is_nav== 1}checked{/if} lay-skin="switch"
				lay-text="ON|OFF">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">图标设置</label>
			<input type="hidden" class="layui-input field-icon" value="{$info.icon}" id="input-icon" name="icon"
			       lay-verify="" autocomplete="off" placeholder="可自定义或使用系统图标">
			<i class="icon iconfont" id="form-icon-preview">{:html_entity_decode('&'.$info.icon)}</i>
			<a href="javascript:;" onclick="x_admin_show('选择图标','{:url(" font")}')" title="选择图标" class="layui-btn
			layui-btn-primary j-iframe-pop fl">选择图标</a>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">排序</label>
			<div class="layui-input-inline">
				<input type="number" name="sort" value="{$info.sort}" required placeholder="序号越小越靠前"
				       autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit lay-filter="formSubmit">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
</div>
</body>

</html>
<script>
    layui.use(['form', 'laydate', 'upload', 'element'], function () {
        var $ = layui.jquery, laydate = layui.laydate, layer = layui.layer, upload = layui.upload,
            element = layui.element, form = layui.form;
        form.on('submit(formSubmit)', function (data) {
            if (data.field.is_nav) {
                data.field.is_nav = 1;
            } else {
                data.field.is_nav = 0;
            }
            var load = layer.load(1);
            $.post("{:url('edit')}", {
                id: '{$info.id}',
                data: data.field
            }, function (res) {
                if (res.success) {
                    layer.msg(res.msg, {icon: 1}, function () {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        parent.location.reload();
                    })
                } else {
                    layer.close(load);
                    layer.msg(res.msg, {icon: 2})
                }
            });
            return false;
        });
    });
</script>
